import request from '../utils/request'

// 购物车相关API接口

export const cartApi = {
  // 获取购物车列表
  getCartList: (params) => request.get('/cart/list', { params }),
  
  // 获取购物车详情
  getCartDetail: (id) => request.get(`/cart/${id}`),
  
  // 添加商品到购物车
  addToCart: (data) => request.post('/cart', data),
  
  // 更新购物车商品数量
  updateCartItemQuantity: (id, quantity) => request.put(`/cart/${id}/quantity`, { quantity }),
  
  // 删除购物车商品
  deleteCartItem: (id) => request.delete(`/cart/${id}`),
  
  // 清空购物车
  clearCart: (userId) => request.delete(`/cart/clear`, { params: { userId } }),
  
  // 批量删除购物车商品
  batchDeleteCartItems: (ids) => request.post('/cart/batch-delete', { ids }),
  
  // 购物车统计
  getCartStatistics: (userId) => request.get('/cart/statistics', { params: { userId } })
}

export default cartApi